﻿@page "/"

@using Y.Blog.Host.Models;
@using Y.Blog.Host.Components;
@inject IMessageService _message;

@inject NavigationManager NavigationManager;

    <div class="section">
        <div class="ownerbox">
            <div class="avatarbox">
                <Avatar Size="240" Src="/images/avatar.jpeg"></Avatar>
            </div>
            <div class="namebox">FourEleven</div>
        </div>
    <div class="intention">
        @Sentence<br />
        <div class="workbox">

            @if(WorkItems?.Any() ?? false)
            {
                foreach(var item in WorkItems)
                {
                    <WorkComponent IconUrl="@item.Icon" 
                    Title="@item.Title" 
                    Description="@item.Description"
                    ClickCallBack="@item.CallBack">
                    </WorkComponent>
                }
            }
            
        </div>
        </div>   
    </div>

@code{

    private string Sentence="夏日夜空繁星般的遐想";

    private List<WorkItem> WorkItems;

    protected async override Task OnInitializedAsync()
    {
        InitWorks();
        await base.OnInitializedAsync();
    }

    protected async override Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender);
    }

    private void Author()
    {
        NavigationManager.NavigateTo("author");
    }

    private void Photo()
    {
        NavigationManager.NavigateTo("photo");
    }

    private void GoMusic()
    {
        NavigationManager.NavigateTo("music/login");
    }

    private void InitWorks()
    {
        WorkItems = new List<WorkItem>();
        WorkItems.Add(new WorkItem("/images/博客园.png", "博客", "尚未开始开发", async () =>
        {
            await _message.Success("别点了，点了没用");
        }));
        WorkItems.Add(new WorkItem("/images/图片.png", "图集", "开发进度10%",Photo));
        WorkItems.Add(new WorkItem("/images/播放.png", "简约版网易云", "开发进度10%",GoMusic));
        WorkItems.Add(new WorkItem("/images/个人空间.png", "个人介绍", "没啥好说的", Author));
    }
}
